﻿using DevExpress.XtraGrid.Demos.util;
using DiaoPaiDaYin;
using DXApplicationTangche.UC.门店下单.DTO;
using DXApplicationTangche.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.原型
{
    public partial class FrmGrid导Excel : DevExpress.XtraEditors.XtraForm
    {
        public OrderDto orderDto = new OrderDto();
        public FrmGrid导Excel()
        {
            InitializeComponent();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出Excel";
            fileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                gridControl1.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            } 
        }

        private void FrmGrid导Excel_Load(object sender, EventArgs e)
        {
            this.gridControl1.DataSource = SQLmtm.GetDataTable("SELECT\n" +
                            "	* \n" +
                            "FROM\n" +
                            "	v_order_p \n" +
                            "ORDER BY\n" +
                            "	v_order_p.ORDER_DATE DESC \n" +
                            "	LIMIT 100");
        }

        private void simpleButtontest_Click(object sender, EventArgs e)
        {
            DataSet result = ExcelUtil.getExcelDatas();
            //
            DataTable testHD = result.Tables["TEST HD"];
            Dictionary<String, String> HD设计点 = new Dictionary<string, string>();
            for (int i = 9; i <= 23; i++)
            {
                HD设计点.Add(testHD.Rows[i]["Column0"].ToString(), testHD.Rows[i]["Column1"].ToString());
            }
            HD设计点.Add(testHD.Rows[25]["Column0"].ToString(), testHD.Rows[25]["Column1"].ToString());
            HD设计点.Add(testHD.Rows[26]["Column0"].ToString(), testHD.Rows[26]["Column1"].ToString());
            DTOTest dTOTestHD = new DTOTest(testHD.Rows[7]["Column0"].ToString(), testHD.Rows[7]["Column1"].ToString(), HD设计点);
            //this.orderDto.build设计点fromExcelHF(dTOTestHD.map);
            //HD设计点面料json
            String jsonHD = FunctionHelper.JsonSerialization(dTOTestHD);
            //
            DataTable testHF = result.Tables["TEST HF"];
            Dictionary<String, String> HF设计点 = new Dictionary<string, string>();
            for (int i = 9; i <= 23; i++)
            {
                HF设计点.Add(testHF.Rows[i]["Column0"].ToString(), testHF.Rows[i]["Column1"].ToString());
            }
            HF设计点.Add(testHF.Rows[25]["Column0"].ToString(), testHF.Rows[25]["Column1"].ToString());
            HF设计点.Add(testHF.Rows[26]["Column0"].ToString(), testHF.Rows[26]["Column1"].ToString());
            DTOTest dTOTestHF = new DTOTest(testHF.Rows[7]["Column0"].ToString(), testHF.Rows[7]["Column1"].ToString(), HF设计点);
            //this.orderDto.build设计点fromExcelHF(dTOTestHF.map);
            //HF设计点面料json
            String jsonHF = FunctionHelper.JsonSerialization(dTOTestHF);
            //
            DataTable testHH = result.Tables["TEST HH"];
            Dictionary<String, String> HH设计点 = new Dictionary<string, string>();
            for (int i = 9; i <= 23; i++)
            {
                HH设计点.Add(testHH.Rows[i]["Column0"].ToString(), testHH.Rows[i]["Column1"].ToString());
            }
            HH设计点.Add(testHH.Rows[25]["Column0"].ToString(), testHH.Rows[25]["Column1"].ToString());
            HH设计点.Add(testHH.Rows[26]["Column0"].ToString(), testHH.Rows[26]["Column1"].ToString());
            DTOTest dTOTestHH = new DTOTest(testHH.Rows[7]["Column0"].ToString(), testHH.Rows[7]["Column1"].ToString(), HH设计点);
            //HH设计点面料json
            String jsonHH = FunctionHelper.JsonSerialization(dTOTestHH);
            //
            DataTable dataTableHDHF = result.Tables["Measurements HD HF"];
            Dictionary<String, String> HDHF测量 = new Dictionary<string, string>();
            for (int i = 14; i <= 23; i++)
            {
                HDHF测量.Add(dataTableHDHF.Rows[i]["Column0"].ToString(), dataTableHDHF.Rows[i]["Column5"].ToString());
            }
            //DTOMeasurementsHDHF dTOMeasurementsHDHF = new DTOMeasurementsHDHF(dataTableHDHF.Rows[12]["Column1"].ToString(), HDHF测量);
            //this.orderDto.build尺寸fromExcelHDHF(dTOMeasurementsHDHF);
            //HDHF尺寸json
            //String jsonSizeHDHF = FunctionHelper.JsonSerialization(dTOMeasurementsHDHF);
            //
            DataTable dataTableHH = result.Tables["Measurements HH"];
            Dictionary<String, String> HH测量 = new Dictionary<string, string>();
            for (int i = 14; i <= 19; i++)
            {
                HH测量.Add(dataTableHH.Rows[i]["Column0"].ToString(), dataTableHH.Rows[i]["Column5"].ToString());
            }
            HH测量.Add(dataTableHH.Rows[24]["Column0"].ToString(), dataTableHH.Rows[24]["Column5"].ToString());
            HH测量.Add(dataTableHH.Rows[25]["Column0"].ToString(), dataTableHH.Rows[25]["Column5"].ToString());
            DTOMeasurementsHH dTOMeasurementsHH = new DTOMeasurementsHH(dataTableHH.Rows[12]["Column1"].ToString(), HH测量);
            //HH尺寸json
            String jsonSizeHH = FunctionHelper.JsonSerialization(dTOMeasurementsHH);

            String jsonOrderDto = FunctionHelper.JsonSerialization(this.orderDto);
        }
    }
}
